home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / xceedzip / BROWSE.BAS next >
BASIC Source File  |  1999-04-26  |  1KB  |  47 lines

  1. Attribute VB_Name = "modBrowse"
  2. Option Explicit
  3.  
  4. Private Type BROWSEINFO
  5.     hwndOwner As Long
  6.     pidlRoot As Long
  7.     pszDisplayName As String
  8.     lpszTitle As String
  9.     ulFlags As Long
  10.     lpfn As Long
  11.     lParam As Long
  12.     iImage As Long
  13. End Type
  14.  
  15. Private Declare Function SHBrowseForFolder Lib "shell32" (ByRef pBrowseInfo As BROWSEINFO) As Long
  16. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidRes As Long, ByVal pszFolder As String) As Long
  17. Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal pVoid As Long)
  18.  
  19. Public Function BrowseForFolder(sFolder As String, ByVal sTitle As String) As Boolean
  20.     Dim bRes As Boolean
  21.     bRes = False
  22.     
  23.     Dim bi As BROWSEINFO, pItemIDList As Long
  24.     
  25.     bi.hwndOwner = 0
  26.     bi.pidlRoot = 0
  27.     bi.pszDisplayName = sFolder
  28.     bi.lpszTitle = sTitle
  29.     bi.ulFlags = 0
  30.     bi.lpfn = 0
  31.     bi.lParam = 0
  32.     bi.iImage = 0
  33.     
  34.     pItemIDList = SHBrowseForFolder(bi)
  35.     
  36.     If pItemIDList Then
  37.         sFolder = Space(261)
  38.         If SHGetPathFromIDList(pItemIDList, sFolder) Then
  39.             bRes = True
  40.         End If
  41.         
  42.         CoTaskMemFree (pItemIDList)
  43.     End If
  44.     
  45.     BrowseForFolder = bRes
  46. End Function
  47.